﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BugTracker.BusinessLogic.Issue
{
    public class IssueMapper : IIssueMapper
    {
        #region IIssueMapper Members

        public DataAccess.Data.Issue Map(BusinessEntities.Entities.Issue.Issue value)
        {
            DataAccess.Data.Issue result = new DataAccess.Data.Issue();
            result.IssueID = value.IssueID;
            result.CategoryID = value.CategoryID;
            result.Name = value.Name;
            result.Description = value.Description;
            result.IssueTypeID = value.IssueTypeID;
            result.IssuePriorityTypeID = value.IssuePriorityTypeID;
            result.IssueStatusTypeID = value.IssueStatusTypeID;
            result.IssueAssigneeID = value.IssueAssigneeID;
            result.ProjectID = value.ProjectID;
            result.Comments = value.Comments;
            result.IssueSeverityTypeID = value.IssueSeverityTypeID;
            result.IssueResolutionTypeID = value.IssueResolutionTypeID;
            result.ReproducedID = value.ReproducedID;
            result.ReportedOn = value.ReportedOn ?? DateTime.MinValue;
            result.ReportedByID = value.ReportedByID;
            result.ResolvedOn = value.ResolvedOn;
            result.IsActive = value.IsActive;
            result.IsDeleted = value.IsDeleted;
            result.RowGuid = value.RowGuid;
            result.CreatedOn = value.CreatedOn;
            result.ModifiedOn = value.ModifiedOn;
            result.UserId = value.UserId;
            return result;
        }

        public BusinessEntities.Entities.Issue.Issue Map(DataAccess.Data.Issue value)
        {
            BusinessEntities.Entities.Issue.Issue result = new BusinessEntities.Entities.Issue.Issue();
            result.IssueID = value.IssueID;
            result.CategoryID = value.CategoryID;
            result.Name = value.Name;
            result.Description = value.Description;
            result.IssueTypeID = value.IssueTypeID;
            result.IssuePriorityTypeID = value.IssuePriorityTypeID;
            result.IssueStatusTypeID = value.IssueStatusTypeID;
            result.IssueAssigneeID = value.IssueAssigneeID;
            result.ProjectID = value.ProjectID;
            result.Comments = value.Comments;
            result.IssueSeverityTypeID = value.IssueSeverityTypeID;
            result.IssueResolutionTypeID = value.IssueResolutionTypeID;
            result.ReproducedID = value.ReproducedID;
            result.ReportedOn = value.ReportedOn;
            result.ReportedByID = value.ReportedByID;
            result.ResolvedOn = value.ResolvedOn;
            result.IsActive = value.IsActive;
            result.IsDeleted = value.IsDeleted;
            result.RowGuid = value.RowGuid;
            result.CreatedOn = value.CreatedOn;
            result.ModifiedOn = value.ModifiedOn;
            result.UserId = value.UserId ?? Guid.Empty;
            return result;
        }

        public void Map(DataAccess.Data.Issue result, BusinessEntities.Entities.Issue.Issue value, bool includeKey = false)
        {
            if (includeKey)
            {
                value.IssueID = result.IssueID;
            }
            value.CategoryID = result.CategoryID;
            value.Name = value.Name;
            value.Description = result.Description;
            value.IssueTypeID = result.IssueTypeID;
            value.IssuePriorityTypeID = result.IssuePriorityTypeID;
            value.IssueStatusTypeID = result.IssueStatusTypeID;
            value.IssueAssigneeID = result.IssueAssigneeID;
            value.ProjectID = result.ProjectID;
            value.Comments = result.Comments;
            value.IssueSeverityTypeID = result.IssueSeverityTypeID;
            value.IssueResolutionTypeID = result.IssueResolutionTypeID;
            value.ReproducedID = result.ReproducedID;
            value.ReportedOn = result.ReportedOn;
            value.ReportedByID = result.ReportedByID;
            value.ResolvedOn = result.ResolvedOn;
            value.IsActive = result.IsActive;
            value.IsDeleted = result.IsDeleted;
            value.RowGuid = result.RowGuid;
            value.CreatedOn = result.CreatedOn;
            value.ModifiedOn = result.ModifiedOn;
            value.UserId = result.UserId ?? Guid.Empty;
        }

        public void Map(BusinessEntities.Entities.Issue.Issue result, DataAccess.Data.Issue value, bool includeKey = false)
        {
            if (includeKey)
            {
                value.IssueID = result.IssueID;
            }
            value.CategoryID = result.CategoryID;
            value.Name = value.Name;
            value.Description = result.Description;
            value.IssueTypeID = result.IssueTypeID;
            value.IssuePriorityTypeID = result.IssuePriorityTypeID;
            value.IssueStatusTypeID = result.IssueStatusTypeID;
            value.IssueAssigneeID = result.IssueAssigneeID;
            value.ProjectID = result.ProjectID;
            value.Comments = result.Comments;
            value.IssueSeverityTypeID = result.IssueSeverityTypeID;
            value.IssueResolutionTypeID = result.IssueResolutionTypeID;
            value.ReproducedID = result.ReproducedID;
            value.ReportedOn = result.ReportedOn ?? DateTime.MinValue;
            value.ReportedByID = result.ReportedByID;
            value.ResolvedOn = result.ResolvedOn;
            value.IsActive = result.IsActive;
            value.IsDeleted = result.IsDeleted;
            value.RowGuid = result.RowGuid;
            value.CreatedOn = result.CreatedOn;
            value.ModifiedOn = result.ModifiedOn;
            value.UserId = result.UserId;
        }

        #endregion
    }
}
